package com.example.maoyanmovie.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import androidx.appcompat.app.AppCompatActivity;
import com.example.maoyanmovie.databinding.ActivitySearchBinding;
import com.example.maoyanmovie.utils.ToastUtils;

public class SearchActivity extends AppCompatActivity {

    private ActivitySearchBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySearchBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        initView();
    }

    private void initView() {
        binding.ivBack.setOnClickListener(v -> finish());

        binding.tvSearch.setOnClickListener(v -> search());
    }

    private void search() {
        String keyword = binding.etSearch.getText().toString().trim();
        if (TextUtils.isEmpty(keyword)) {
            ToastUtils.showShort(this, "请输入搜索关键词");
            return;
        }

        ToastUtils.showShort(this, "搜索：" + keyword);
        // 这里可以实现搜索逻辑
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        binding = null;
    }
}
